
public class Queue {
	
	private class Node{
		int     item_; 
	    Node 	next_;
	    Node(int item, Node next ){
	         item_=item; next_=next;
	      } 
	}
	private Node  front_;
	private Node rear_;


	public static Queue create() {
		Queue q= new Queue();
		q.front_=null; 
		q.rear_=null;
		return q;
	}

	public static void enqueue(Queue q, int i) {
		Node n = q.new Node(i,null);
		if(isEmpty(q))
			q.front_= q.rear_= n;
		else
			q.rear_=q.rear_.next_=n;
	}
	
	public static void dequeue(Queue q) {
		if(q.front_!=null)
			q.front_=q.front_.next_;
	}

	public static int front(Queue q) {
		if(q.front_!=null)
			return q.front_.item_;
		return 0;
	}

	//we can check onlt front or rear
	public static Boolean isEmpty(Queue q) {
		return q.front_==null?true:false;
	}

}
